package demo8;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * 实际开发中,会出现框架之间的整合工作,多个框架协同工作
 *
 *
 *
 */
@Component
public class DBUtil {
    /**
     * DruidDataSource没有@Component注解,不受Spring自动扫描管理
     */
    @Autowired
    private DruidDataSource ds;

    public Connection getConnection() throws SQLException{
        return ds.getConnection();
    }
}
